// pages/selcet/selcet.js
import * as selectData from 'selectdata.js';
Page({

  data: {  
    selectedWord: '',
    // 直接在 data 对象中定义初始数据  
  },    
  onLoad: function() {  
    this.setData({  
      selectedWord: 'hello' 
    });  
  }  ,
  select: function(dataArray){
    if (dataArray.length === 0) {  
      return 0; 
    }  
    const randomIndex = Math.floor(Math.random() * dataArray.length);  
    const selectedObject = dataArray[randomIndex]; 
    return selectedObject;  
  },
  onselectgaokao:function(e){
   const sWord=this.select(selectData.datagaokao/*this.data.datasiji*/);
   wx.navigateTo({
    url: `/pages/main/main?id=${sWord.word}&level=gaokao`,
  })
  } ,
  onselectsiji:function(e){
   const sWord=this.select(selectData.datasiji);
   wx.navigateTo({
    url:  `/pages/main/main?id=${sWord.word}&level=siji`,
  })
  },
  
  onselectliuji:function(e){
   const sWord=this.select(selectData.dataliuji);
   wx.navigateTo({
    url: `/pages/main/main?id=${sWord.word}&level=liuji`,
  })
  },
})
